/**
 * \* Created with IntelliJ IDEA.
 * \* User: 冯若航
 * \* Date: 2021/5/11
 * \* Time: 22:07
 * \* To change this template use File | Settings | File Templates.
 * \* Description:
 * \
 */
public class 比较版本号 {
    public int compareVersion(String version1, String version2) {
        int n1=version1.length(),n2=version2.length();
        int left1=0,left2=0;

        while (left1<n1||left2<n2){
            int num1=0,num2=0;
            while (left1<n1&&version1.charAt(left1)!='.'){
                num1=num1*10+version1.charAt(left1)-'0';
                left1++;
            }
            while (left2<n2&&version2.charAt(left2)!='.'){
                num2=num2*10+version2.charAt(left2)-'0';
                left2++;
            }
            if(num1>num2){
                return 1;
            }else if(num1<num2){
                return -1;
            }else {
                left1++;
                left2++;
            }
        }
        return 0;
    }
}